#include <iostream>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
// 生成 Chebyshev 节点
void generateChebyshevNodes(int n, double* nodes) {
    for (int i = 0; i < n; i++) {
        nodes[i] = cos(M_PI * (i + 0.5) / n); // Chebyshev 节点
    }
}

// 计算 Chebyshev 插值多项式的值
double Chebyshev(double* x, double* y, int n, double a) {
    double result = 0.0;
    for (int i = 0; i < n; i++) {
        double term = y[i];
        for (int j = 0; j < n; j++) {
            if (j != i) {
                term *= (a - x[j]) / (x[i] - x[j]);
            }
        }
        result += term;
    }
    return result;
}
